<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Redis基础 | flybird&#39;s blog</title>
    <meta name="generator" content="VuePress 1.8.0">
    <link rel="icon" href="https://infinitypro-img.infinitynewtab.com/custom-icon/8001de1jd3n68lbfnxxt564xvb0vl5.png?imageMogr2/thumbnail/240x/format/webp/blur/1x0/quality/100|imageslim">
    <script language="javascript" type="text/javascript" src="https://cdn.staticfile.org/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="/js/MouseClickEffect.js"></script>
    <meta name="description" content="Stay hungry, Stay foolish">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.324c77a5.css" as="style"><link rel="preload" href="/assets/js/app.55c4f7c3.js" as="script"><link rel="preload" href="/assets/js/5.86109dd2.js" as="script"><link rel="preload" href="/assets/js/1.74974061.js" as="script"><link rel="preload" href="/assets/js/2.ab8aa845.js" as="script"><link rel="preload" href="/assets/js/84.6118b266.js" as="script"><link rel="preload" href="/assets/js/18.cfe435f1.js" as="script"><link rel="prefetch" href="/assets/js/10.1f3187f9.js"><link rel="prefetch" href="/assets/js/11.67fe3d1f.js"><link rel="prefetch" href="/assets/js/12.0052f325.js"><link rel="prefetch" href="/assets/js/13.bad60b36.js"><link rel="prefetch" href="/assets/js/14.6a893378.js"><link rel="prefetch" href="/assets/js/15.899648d3.js"><link rel="prefetch" href="/assets/js/16.0575f88b.js"><link rel="prefetch" href="/assets/js/17.86f820d7.js"><link rel="prefetch" href="/assets/js/19.1d1c7b67.js"><link rel="prefetch" href="/assets/js/20.218819f6.js"><link rel="prefetch" href="/assets/js/21.223949af.js"><link rel="prefetch" href="/assets/js/22.eb6ea80c.js"><link rel="prefetch" href="/assets/js/23.cf07ba0c.js"><link rel="prefetch" href="/assets/js/24.eeb9d511.js"><link rel="prefetch" href="/assets/js/25.4be64ae7.js"><link rel="prefetch" href="/assets/js/26.6aea0ced.js"><link rel="prefetch" href="/assets/js/27.7540f161.js"><link rel="prefetch" href="/assets/js/28.d88a26e6.js"><link rel="prefetch" href="/assets/js/29.7edc404c.js"><link rel="prefetch" href="/assets/js/30.b3c16bef.js"><link rel="prefetch" href="/assets/js/31.63392d40.js"><link rel="prefetch" href="/assets/js/32.b90695c8.js"><link rel="prefetch" href="/assets/js/33.669186a5.js"><link rel="prefetch" href="/assets/js/34.57a9b7fc.js"><link rel="prefetch" href="/assets/js/35.81d5b8b3.js"><link rel="prefetch" href="/assets/js/36.466fde53.js"><link rel="prefetch" href="/assets/js/37.ff7b9321.js"><link rel="prefetch" href="/assets/js/38.132de18a.js"><link rel="prefetch" href="/assets/js/39.80a51963.js"><link rel="prefetch" href="/assets/js/40.e7d6c67d.js"><link rel="prefetch" href="/assets/js/41.d195ea4b.js"><link rel="prefetch" href="/assets/js/42.dbe1a8f1.js"><link rel="prefetch" href="/assets/js/43.2ea02aec.js"><link rel="prefetch" href="/assets/js/44.294015bc.js"><link rel="prefetch" href="/assets/js/45.3cf9c326.js"><link rel="prefetch" href="/assets/js/46.8cc95701.js"><link rel="prefetch" href="/assets/js/47.ddf6cc44.js"><link rel="prefetch" href="/assets/js/48.ba718ca6.js"><link rel="prefetch" href="/assets/js/49.feee5279.js"><link rel="prefetch" href="/assets/js/50.6f2d0d0d.js"><link rel="prefetch" href="/assets/js/51.ebe1eb07.js"><link rel="prefetch" href="/assets/js/52.3e47f7ae.js"><link rel="prefetch" href="/assets/js/53.861fb703.js"><link rel="prefetch" href="/assets/js/54.f7d3a937.js"><link rel="prefetch" href="/assets/js/55.d90baa98.js"><link rel="prefetch" href="/assets/js/56.ba7f3256.js"><link rel="prefetch" href="/assets/js/57.90441d7f.js"><link rel="prefetch" href="/assets/js/58.a0d58abc.js"><link rel="prefetch" href="/assets/js/59.7f649313.js"><link rel="prefetch" href="/assets/js/6.00dfc51e.js"><link rel="prefetch" href="/assets/js/60.60dd83d2.js"><link rel="prefetch" href="/assets/js/61.b84cd1ef.js"><link rel="prefetch" href="/assets/js/62.8ed6541f.js"><link rel="prefetch" href="/assets/js/63.84bfbbbf.js"><link rel="prefetch" href="/assets/js/64.01c483db.js"><link rel="prefetch" href="/assets/js/65.278ce63e.js"><link rel="prefetch" href="/assets/js/66.cb493053.js"><link rel="prefetch" href="/assets/js/67.8c2201b6.js"><link rel="prefetch" href="/assets/js/68.46467c87.js"><link rel="prefetch" href="/assets/js/69.ee34297d.js"><link rel="prefetch" href="/assets/js/7.aaee1baa.js"><link rel="prefetch" href="/assets/js/70.3a016bcf.js"><link rel="prefetch" href="/assets/js/71.1cb787d0.js"><link rel="prefetch" href="/assets/js/72.2ee0677e.js"><link rel="prefetch" href="/assets/js/73.3e1e1729.js"><link rel="prefetch" href="/assets/js/74.947d7cd3.js"><link rel="prefetch" href="/assets/js/75.2e5c7344.js"><link rel="prefetch" href="/assets/js/76.6c098cc2.js"><link rel="prefetch" href="/assets/js/77.03fd3a89.js"><link rel="prefetch" href="/assets/js/78.38d2d963.js"><link rel="prefetch" href="/assets/js/79.ea508df9.js"><link rel="prefetch" href="/assets/js/8.35d0b089.js"><link rel="prefetch" href="/assets/js/80.b2b1dda3.js"><link rel="prefetch" href="/assets/js/81.d7db5a4d.js"><link rel="prefetch" href="/assets/js/82.1c148069.js"><link rel="prefetch" href="/assets/js/83.51e2c0d0.js"><link rel="prefetch" href="/assets/js/85.55a516f8.js"><link rel="prefetch" href="/assets/js/86.3b73f7a9.js"><link rel="prefetch" href="/assets/js/87.123149cb.js"><link rel="prefetch" href="/assets/js/88.f87dde9d.js"><link rel="prefetch" href="/assets/js/89.06c3b9a1.js"><link rel="prefetch" href="/assets/js/9.58e6c220.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.080f3458.js">
    <link rel="stylesheet" href="/assets/css/0.styles.324c77a5.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div><div class="theme-container" data-v-0b87bb44><div data-v-0b87bb44><div id="loader-wrapper" class="loading-wrapper" data-v-1c4f0192 data-v-0b87bb44 data-v-0b87bb44><div class="loader-main" data-v-1c4f0192><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-73c95a87 data-v-0b87bb44 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>flybird's blog</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-0b87bb44><header class="navbar" data-v-0b87bb44><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">flybird's blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask" data-v-0b87bb44></div> <aside class="sidebar" data-v-0b87bb44><div class="personal-info-wrapper" data-v-7e653f02><img src="/vuepress/my-head.png" alt="author-avatar" class="personal-img" data-v-7e653f02> <h3 class="name" data-v-7e653f02>
    flybird
  </h3> <div class="num" data-v-7e653f02><div data-v-7e653f02><h3 data-v-7e653f02>63</h3> <h6 data-v-7e653f02>文章</h6></div> <div data-v-7e653f02><h3 data-v-7e653f02>26</h3> <h6 data-v-7e653f02>标签</h6></div></div> <hr data-v-7e653f02></div> <nav class="nav-links"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/views/" aria-current="page" class="sidebar-link">概览</a></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>大数据</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>中间件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>后端</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/views/java/ArrayList.html" class="sidebar-link">ArrayList底层实现和原理</a></li><li><a href="/views/java/HashMap.html" class="sidebar-link">HashMap底层实现和原理</a></li><li><a href="/views/java/docker.html" class="sidebar-link">Docker的基本了解和使用</a></li><li><a href="/views/java/itext.html" class="sidebar-link">itext:PDF导出</a></li><li><a href="/views/java/poi.html" class="sidebar-link">poi多线程多sheet导出Excel,csv</a></li><li><a href="/views/java/quartz.html" class="sidebar-link">Quartz定时任务</a></li><li><a href="/views/java/rabbitmq001.html" class="sidebar-link">RabbitMQ基础</a></li><li><a href="/views/java/rabbitmq002.html" class="sidebar-link">RabbitMQ进阶</a></li><li><a href="/views/java/redis01.html" aria-current="page" class="active sidebar-link">Redis基础</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis01.html#简介" class="sidebar-link">简介</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#redis提供的5中数据类型" class="sidebar-link">redis提供的5中数据类型</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#redis使用场景" class="sidebar-link">redis使用场景</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#redis常用命令" class="sidebar-link">redis常用命令:</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/views/java/redis01.html#string" class="sidebar-link">string:</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#hash-效率最高" class="sidebar-link">hash:(效率最高)</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#list" class="sidebar-link">list:</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#set-一般用交集并集" class="sidebar-link">set:(一般用交集并集)</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#zset" class="sidebar-link">zset:</a></li></ul></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#事务-不推荐使用" class="sidebar-link">事务：(不推荐使用)</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#简单-spring配置jedis-相当于jdbc" class="sidebar-link">简单 spring配置jedis(相当于jdbc):</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#详细-在spring中使用redis" class="sidebar-link">详细 在spring中使用redis</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#详细-在springboot中使用redis" class="sidebar-link">详细 在springboot中使用redis</a></li><li class="sidebar-sub-header"><a href="/views/java/redis01.html#redis缓存与数据库同步" class="sidebar-link">redis缓存与数据库同步</a></li></ul></li><li><a href="/views/java/redis02.html" class="sidebar-link">Redis终结</a></li><li><a href="/views/java/SSH.html" class="sidebar-link">SSH架构知识点概览</a></li><li><a href="/views/java/jwt.html" class="sidebar-link">JWT登陆认证</a></li><li><a href="/views/java/swagger2.html" class="sidebar-link">Swagger2的基本了解和使用</a></li><li><a href="/views/java/thread.html" class="sidebar-link">多线程和线程池基础</a></li><li><a href="/views/java/ThreadPool.html" class="sidebar-link">线程池进阶详解</a></li><li><a href="/views/java/ThreadLocal.html" class="sidebar-link">ThreadLocal简介</a></li><li><a href="/views/java/annotationLog.html" class="sidebar-link">注解+AOP实现日志记录</a></li><li><a href="/views/java/jvm.html" class="sidebar-link">jvm和GC</a></li><li><a href="/views/java/JUC.html" class="sidebar-link">JUC小结</a></li><li><a href="/views/java/javaLock.html" class="sidebar-link">Java中的各种锁</a></li><li><a href="/views/java/mysql_explain.html" class="sidebar-link">MySQL慢查询优化</a></li><li><a href="/views/java/ReentrantLock.html" class="sidebar-link">ReentrantLock 详解</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-73c95a87 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>Redis基础</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div data-v-0b87bb44><main class="page"><!----> <div class="page-title" style="display:none;"><h1>Redis基础</h1> <hr> <div data-v-7b2e794a><i class="iconfont reco-account" data-v-7b2e794a><span data-v-7b2e794a>flybird</span></i> <i class="iconfont reco-date" data-v-7b2e794a><span data-v-7b2e794a>2019-08-04 18:41:12</span></i> <i class="iconfont reco-eye" data-v-7b2e794a><span id="/views/java/redis01.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-7b2e794a><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-7b2e794a><span class="tag-item" data-v-7b2e794a>
      Redis
    </span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><div id="boxx" data-v-f4ca0dac><div data-v-f4ca0dac><p v-if="true" class="custom-block-title" data-v-f4ca0dac></p> <p v-if="true" data-v-f4ca0dac></p></div></div> <p>对Redis的总结：常用命令、使用场景、在Spring中使用、在SpringBoot中是使用</p> <p></p><div class="table-of-contents"><ul><li><a href="#简介">简介</a></li><li><a href="#redis提供的5中数据类型">redis提供的5中数据类型</a></li><li><a href="#redis使用场景">redis使用场景</a></li><li><a href="#redis常用命令">redis常用命令:</a><ul><li><a href="#string">string:</a></li><li><a href="#hash-效率最高">hash:(效率最高)</a></li><li><a href="#list">list:</a></li><li><a href="#set-一般用交集并集">set:(一般用交集并集)</a></li><li><a href="#zset">zset:</a></li></ul></li><li><a href="#事务-不推荐使用">事务：(不推荐使用)</a></li><li><a href="#简单-spring配置jedis-相当于jdbc">简单 spring配置jedis(相当于jdbc):</a></li><li><a href="#详细-在spring中使用redis">详细 在spring中使用redis</a></li><li><a href="#详细-在springboot中使用redis">详细 在springboot中使用redis</a></li><li><a href="#redis缓存与数据库同步">redis缓存与数据库同步</a></li></ul></div><p></p> <h2 id="简介"><a href="#简介" class="header-anchor">#</a> 简介</h2> <p><strong>Redis(非关系型数据库)：</strong> 先开启服务器端service,再打开客户端cil</p> <p><strong>Redis</strong>和<strong>MongoDB</strong>是当前使用最广泛的NoSQL，而就Redis技术而言，它的性能十分优越，可以<strong>支持每秒十几万此的读/写操作</strong>，其性能远超数据库，并且还<strong>支持集群、分布式、主从同步等</strong>配置，原则上可以无限扩展，让更多的数据存储在内存中，更让人欣慰的是它还<strong>支持一定的事务能力</strong>，这保证了高并发的场景下数据的安全和一致性</p> <blockquote><p>redis 特点</p></blockquote> <ol><li>单线程,底层c语言开发,默认16个数据库(下表从0开始)</li> <li>支持事务(原子性)</li> <li>redis持久化 -&gt; 存储在磁盘中,占用内存</li> <li>99%都是部署在Linux系统上</li></ol> <blockquote><p>redis 优缺点</p></blockquote> <ol><li><p>优点: (1) 读写性能优异</p> <p>​		  (2)支持数据持久化，支持AOF和RDB两种持久化方式</p> <p>​		  (3)支持主从复制，主机会自动将数据同步到从机，可以进行读写分离</p> <p>​		  (4)数据结构丰富：除了支持string类型的value外还支持string、hash、set、sortedset、list等数据结构</p></li> <li><p>缺点: (1) 缺少结构化(没有表和字段的概念)，可读性查，不能使用where条件</p> <p>​		  (2) 由于是内存数据库，费内存</p> <p>​		  (3)不具备自动容错和恢复功能，主机从机的宕机都会导致前端部分读写请求失败，需要等待机器重启或者手动切换前端的IP才能恢复	--- <a href="https://www.cnblogs.com/rzqz/p/7440249.html" target="_blank" rel="noopener noreferrer">更多<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li></ol> <h2 id="redis提供的5中数据类型"><a href="#redis提供的5中数据类型" class="header-anchor">#</a> redis提供的5中数据类型</h2> <ol><li>string	最大存储长度为512M</li> <li>list	(linkedlist)双向列表,分页</li> <li>hash  hashmap</li> <li>set 	hashset 	无序</li> <li>zset	treeset 	 有序</li></ol> <h2 id="redis使用场景"><a href="#redis使用场景" class="header-anchor">#</a> redis使用场景</h2> <ol><li>缓存  替数据库 MySQL Oracle 分担一部分压力</li> <li>分页  点赞  踩  统计用户访问量  在线人数</li> <li>分布式锁</li> <li>单点登录 spring session cookie session</li></ol> <h2 id="redis常用命令"><a href="#redis常用命令" class="header-anchor">#</a> redis常用命令:</h2> <ul><li>flushdb  清空当前的数据库(慎用)</li> <li>flushall   清空所有的数据库(根本就不要用)</li> <li>select 15 切换到第16个数据库</li></ul> <h3 id="string"><a href="#string" class="header-anchor">#</a> string:</h3> <table><thead><tr><th>命令</th> <th>释义</th></tr></thead> <tbody><tr><td>set key value</td> <td>设置key和value</td></tr> <tr><td>get key</td> <td>通过key拿值</td></tr> <tr><td>del key1,key2,..</td> <td>删除一个或多个数据</td></tr> <tr><td>expire key 10</td> <td>设置消亡时间，10秒后这个key就删除</td></tr> <tr><td>keys <em>k</em></td> <td>查询所有的包含k的key</td></tr> <tr><td>ttl key</td> <td>当设置消亡时间后,以秒为单位返回key的剩余时间 (-1代表没有设置,-2代表已被删除)</td></tr> <tr><td>move key1 15</td> <td>把key1移动到第16个数据库(从0开始)</td></tr> <tr><td>rename key1 key2</td> <td>把key1重新命名为key2 （如果key2已存在那会覆盖 ）</td></tr> <tr><td>RENAMENX</td> <td>当且仅当 newkey 不存在时，将 key 改名为 newkey</td></tr> <tr><td>append key1 valueX</td> <td>如果key1存在就把valueX追加到原先value的末尾,key1不存在就是set</td></tr> <tr><td>mset k1 v1 k2 v2 ..</td> <td>批量新增</td></tr> <tr><td>mget k1 k2 k3 ...</td> <td>批量拿值</td></tr> <tr><td>incr key</td> <td>将 key 中储存的数字值自动增一</td></tr> <tr><td>incrby key 数字</td> <td>将 key 所储存的值加上增量</td></tr> <tr><td>decrby key 数字</td> <td>将 key 所储存的值减上数字</td></tr> <tr><td>setnx key value</td> <td>将 key 的值设为 value ，当且仅当 key 不存在。若给定的 key 已经存在，则SETNX 不做任何动作。</td></tr> <tr><td>strlen key</td> <td>返回key所对应的value的长度</td></tr></tbody></table> <h3 id="hash-效率最高"><a href="#hash-效率最高" class="header-anchor">#</a> hash:(效率最高)</h3> <table><thead><tr><th>命令</th> <th>释义</th></tr></thead> <tbody><tr><td>hset key(相当于表) field(字段) value(值)</td> <td>建表和赋值 key必须唯一,不然会覆盖</td></tr> <tr><td>hget key field</td> <td>取值</td></tr> <tr><td>hkeys key</td> <td>获取key中所有的字段</td></tr> <tr><td>hvals key</td> <td>获取key中所有的值</td></tr></tbody></table> <h3 id="list"><a href="#list" class="header-anchor">#</a> list:</h3> <table><thead><tr><th>命令</th> <th>释义</th></tr></thead> <tbody><tr><td>lpush key v1 v2 v3</td> <td>在key中依次插入3个值,每次插入都放在最左边</td></tr> <tr><td>lrange key start(起始下标) stop(结束下标)</td> <td>取出key中从下标start到stop(包含)的值</td></tr> <tr><td>lrange list (当前页-1)<em>rows page</em>rows-1</td> <td>分页</td></tr></tbody></table> <h3 id="set-一般用交集并集"><a href="#set-一般用交集并集" class="header-anchor">#</a> set:(一般用交集并集)</h3> <table><thead><tr><th>命令</th> <th>释义</th></tr></thead> <tbody><tr><td>sadd key 元素1 元素2  ...</td> <td>添加多个元素到集合中</td></tr> <tr><td>smembers key</td> <td>取出集合中的所有成员</td></tr></tbody></table> <h3 id="zset"><a href="#zset" class="header-anchor">#</a> zset:</h3> <table><thead><tr><th>命令</th> <th>释义</th></tr></thead> <tbody><tr><td>zadd key score(值) member(字段)</td> <td>score必须得是int/float</td></tr> <tr><td>zrange key start stop</td> <td>获取所有的member</td></tr> <tr><td>zrange key start stop withscores</td> <td>获取所有的member和score</td></tr></tbody></table> <h2 id="事务-不推荐使用"><a href="#事务-不推荐使用" class="header-anchor">#</a> 事务：(不推荐使用)</h2> <p>​	multi			开启事务
​	  	...添加队列操作
​	exec			执行事务</p> <p>​	redis支持lua脚本：
​	//key[]/argv[]可以有多个,2表示有两个key,后边是依次给key和argv赋值
​	eval &quot;return {keys[1],key[2],argv[1],argv[2]}&quot; 2 key1 key2 1 2</p> <blockquote><p>注意：redis缓存操作和数据库操作若要成为一个事务,即当数据库操作添加失败时也不能进到缓存中
所以我们只能造一个异常出来,因为事务的异常只能抛
事务的底层有一个try cath ,会把我们自己try的捕获,当出问题时我们try会使事务失效</p></blockquote> <h2 id="简单-spring配置jedis-相当于jdbc"><a href="#简单-spring配置jedis-相当于jdbc" class="header-anchor">#</a> 简单 spring配置jedis(相当于jdbc):</h2> <ol start="0"><li>导入jar包</li> <li>在xml中配置数据源 JedisPoolConfig
​		maxTotal	 最大连接数
​		minIdle		最小空闲数
​		minIdle		最大空闲数
​		maxWaitMillis 	超时时间</li> <li>客户端连接服务端操作(没有set方法,只能通过构造方法注入属性) JedisPool
​		poolConfig 	注入1连接池
​		host		IP地址
​		port		端口号</li></ol> <h2 id="详细-在spring中使用redis"><a href="#详细-在spring中使用redis" class="header-anchor">#</a> 详细 在spring中使用redis</h2> <ol><li><strong>配置xml applicationContext-redis.xml</strong></li></ol> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code>	<span class="token comment">&lt;!-- redis单机版 --&gt;</span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>jedisPool<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>redis.clients.jedis.JedisPool<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>constructor-arg</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>host<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>192.168.25.153<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>	
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>constructor-arg</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>port<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>6379<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>	
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
	<span class="token comment">&lt;!-- 我们封装的jedis常用方法类 --&gt;</span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>jedisClientPool<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.taotao.jedis.JedisClientPool<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>

	<span class="token comment">&lt;!-- redis集群 --&gt;</span>
	<span class="token comment">&lt;!-- &lt;bean id=&quot;jedisCluster&quot; class=&quot;redis.clients.jedis.JedisCluster&quot;&gt;
		&lt;constructor-arg&gt;
			&lt;set&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7001&quot;/&gt;
				&lt;/bean&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7002&quot;/&gt;
				&lt;/bean&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7003&quot;/&gt;
				&lt;/bean&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7004&quot;/&gt;
				&lt;/bean&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7005&quot;/&gt;
				&lt;/bean&gt;
				&lt;bean class=&quot;redis.clients.jedis.HostAndPort&quot;&gt;
					&lt;constructor-arg name=&quot;host&quot; value=&quot;192.168.25.153&quot;/&gt;
					&lt;constructor-arg name=&quot;port&quot; value=&quot;7006&quot;/&gt;
				&lt;/bean&gt;
			&lt;/set&gt;
		&lt;/constructor-arg&gt;
	&lt;/bean&gt;
	&lt;bean id=&quot;jedisClientCluster&quot; class=&quot;com.taotao.jedis.JedisClientCluster&quot;/&gt; --&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ol start="2"><li><strong>可配置的redis连接池</strong></li></ol> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">// 池基本配置</span>
<span class="token class-name">JedisPoolConfig</span> config <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JedisPoolConfig</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//是否启用后进先出, 默认true</span>
config<span class="token punctuation">.</span><span class="token function">setLifo</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//最大空闲连接数, 默认8个</span>
config<span class="token punctuation">.</span><span class="token function">setMaxIdle</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//最大连接数, 默认8个</span>
config<span class="token punctuation">.</span><span class="token function">setMaxTotal</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间,  默认-1</span>
config<span class="token punctuation">.</span><span class="token function">setMaxWaitMillis</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//逐出连接的最小空闲时间 默认1800000毫秒(30分钟)</span>
config<span class="token punctuation">.</span><span class="token function">setMinEvictableIdleTimeMillis</span><span class="token punctuation">(</span><span class="token number">1800000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//最小空闲连接数, 默认0</span>
config<span class="token punctuation">.</span><span class="token function">setMinIdle</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3</span>
config<span class="token punctuation">.</span><span class="token function">setNumTestsPerEvictionRun</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//对象空闲多久后逐出, 当空闲时间&gt;该值 且 空闲连接&gt;最大空闲数 时直接逐出,不再根据MinEvictableIdleTimeMillis判断  (默认逐出策略)</span>
config<span class="token punctuation">.</span><span class="token function">setSoftMinEvictableIdleTimeMillis</span><span class="token punctuation">(</span><span class="token number">1800000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//在获取连接的时候检查有效性, 默认false</span>
config<span class="token punctuation">.</span><span class="token function">setTestOnBorrow</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//在空闲时检查有效性, 默认false</span>
config<span class="token punctuation">.</span><span class="token function">setTestWhileIdle</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 使用配置创建连接池</span>
jedisPool <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JedisPool</span><span class="token punctuation">(</span>config<span class="token punctuation">,</span> host<span class="token punctuation">,</span> port<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">Jedis</span> jedis <span class="token operator">=</span> pool<span class="token punctuation">.</span><span class="token function">getResource</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 从连接池中获取单个连接</span>
<span class="token comment">//jedis.auth(&quot;password&quot;);// 如果需要密码</span>

<span class="token comment">//...各种jedis操作</span>

<span class="token comment">//jedis.close();//用完记得关闭连接</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><ol start="3"><li><strong>对redis单机版、连接池版、集群版的简单测试</strong></li></ol> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>taotao<span class="token punctuation">.</span>jedis</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashSet</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Set</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">redis<span class="token punctuation">.</span>clients<span class="token punctuation">.</span>jedis<span class="token punctuation">.</span></span><span class="token class-name">HostAndPort</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">redis<span class="token punctuation">.</span>clients<span class="token punctuation">.</span>jedis<span class="token punctuation">.</span></span><span class="token class-name">Jedis</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">redis<span class="token punctuation">.</span>clients<span class="token punctuation">.</span>jedis<span class="token punctuation">.</span></span><span class="token class-name">JedisCluster</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">redis<span class="token punctuation">.</span>clients<span class="token punctuation">.</span>jedis<span class="token punctuation">.</span></span><span class="token class-name">JedisPool</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">TestJedis</span> <span class="token punctuation">{</span>

	<span class="token annotation punctuation">@Test</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testJedis</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
		<span class="token comment">//创建一个jedis对象，需要指定服务的ip和端口号</span>
		<span class="token class-name">Jedis</span> jedis <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Jedis</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">6379</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//直接操作数据库</span>
		jedis<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token string">&quot;jedis-key&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;1234&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">String</span> result <span class="token operator">=</span> jedis<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&quot;jedis-key&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//关闭jedis</span>
		jedis<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token annotation punctuation">@Test</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testJedisPool</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
		<span class="token comment">//创建一个数据库连接池对象（单例），需要指定服务的ip和端口号</span>
		<span class="token class-name">JedisPool</span> jedisPool <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JedisPool</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">6379</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//从连接池中获得连接</span>
		<span class="token class-name">Jedis</span> jedis <span class="token operator">=</span> jedisPool<span class="token punctuation">.</span><span class="token function">getResource</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//使用Jedis操作数据库（方法级别使用）</span>
		<span class="token class-name">String</span> result <span class="token operator">=</span> jedis<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&quot;jedis-key&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//一定要关闭Jedis连接</span>
		jedis<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//系统关闭前关闭连接池</span>
		jedisPool<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	
	<span class="token annotation punctuation">@Test</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testJedisCluster</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
		<span class="token comment">//创建一个JedisCluster对象，构造参数Set类型，集合中每个元素是HostAndPort类型</span>
		<span class="token class-name">Set</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HostAndPort</span><span class="token punctuation">&gt;</span></span> nodes <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashSet</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//向集合中添加节点</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7001</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7002</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7003</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7004</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7005</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		nodes<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HostAndPort</span><span class="token punctuation">(</span><span class="token string">&quot;192.168.25.153&quot;</span><span class="token punctuation">,</span> <span class="token number">7006</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">JedisCluster</span> jedisCluster <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JedisCluster</span><span class="token punctuation">(</span>nodes<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//直接使用JedisCluster操作redis，自带连接池。jedisCluster对象可以是单例 的。</span>
		jedisCluster<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token string">&quot;cluster-test&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;hello jedis cluster&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">String</span> string <span class="token operator">=</span> jedisCluster<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&quot;cluster-test&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>string<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">//系统关闭前关闭JedisCluster</span>
		jedisCluster<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br></div></div><h2 id="详细-在springboot中使用redis"><a href="#详细-在springboot中使用redis" class="header-anchor">#</a> 详细 在springboot中使用redis</h2> <ol><li><strong>在SpringBoot中添加Redis依赖：</strong></li></ol> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token comment">&lt;!--redis依赖配置--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.springframework.boot<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spring-boot-starter-data-redis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ol start="2"><li><strong>在SpringBoot中配置<code>application-dev.yml</code></strong></li></ol> <div class="language-yml line-numbers-mode"><pre class="language-yml"><code>  <span class="token key atrule">redis</span><span class="token punctuation">:</span>
    <span class="token key atrule">host</span><span class="token punctuation">:</span> localhost <span class="token comment"># Redis服务器地址</span>
    <span class="token key atrule">database</span><span class="token punctuation">:</span> <span class="token number">0</span> <span class="token comment"># Redis数据库索引（默认为0）</span>
    <span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">6379</span> <span class="token comment"># Redis服务器连接端口</span>
    <span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token comment"># Redis服务器连接密码（默认为空）</span>
    <span class="token key atrule">jedis</span><span class="token punctuation">:</span>
      <span class="token key atrule">pool</span><span class="token punctuation">:</span>
        <span class="token key atrule">max-active</span><span class="token punctuation">:</span> <span class="token number">8</span> <span class="token comment"># 连接池最大连接数（使用负值表示没有限制）</span>
        <span class="token key atrule">max-wait</span><span class="token punctuation">:</span> <span class="token punctuation">-</span>1ms <span class="token comment"># 连接池最大阻塞等待时间（使用负值表示没有限制）</span>
        <span class="token key atrule">max-idle</span><span class="token punctuation">:</span> <span class="token number">8</span> <span class="token comment"># 连接池中的最大空闲连接</span>
        <span class="token key atrule">min-idle</span><span class="token punctuation">:</span> <span class="token number">0</span> <span class="token comment"># 连接池中的最小空闲连接</span>
    <span class="token key atrule">timeout</span><span class="token punctuation">:</span> 3000ms <span class="token comment"># 连接超时时间（毫秒）</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ol start="3"><li><strong>常用的redis操作</strong></li></ol> <blockquote><p>通过springboot自动配置的<strong>StringRedisTemplate</strong>对象进行Redis的读写操作</p></blockquote> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>macro<span class="token punctuation">.</span>mall<span class="token punctuation">.</span>portal<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>macro<span class="token punctuation">.</span>mall<span class="token punctuation">.</span>portal<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">RedisService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>data<span class="token punctuation">.</span>redis<span class="token punctuation">.</span>core<span class="token punctuation">.</span></span><span class="token class-name">StringRedisTemplate</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>concurrent<span class="token punctuation">.</span></span><span class="token class-name">TimeUnit</span><span class="token punctuation">;</span>

<span class="token comment">/**
 * redis操作Service的实现类
 */</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">RedisServiceImpl</span> <span class="token keyword">implements</span> <span class="token class-name">RedisService</span> <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">StringRedisTemplate</span> stringRedisTemplate<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">set</span><span class="token punctuation">(</span><span class="token class-name">String</span> key<span class="token punctuation">,</span> <span class="token class-name">String</span> value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        stringRedisTemplate<span class="token punctuation">.</span><span class="token function">opsForValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>key<span class="token punctuation">,</span> value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">get</span><span class="token punctuation">(</span><span class="token class-name">String</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> stringRedisTemplate<span class="token punctuation">.</span><span class="token function">opsForValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">expire</span><span class="token punctuation">(</span><span class="token class-name">String</span> key<span class="token punctuation">,</span> <span class="token keyword">long</span> expire<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> stringRedisTemplate<span class="token punctuation">.</span><span class="token function">expire</span><span class="token punctuation">(</span>key<span class="token punctuation">,</span> expire<span class="token punctuation">,</span> <span class="token class-name">TimeUnit</span><span class="token punctuation">.</span>SECONDS<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">remove</span><span class="token punctuation">(</span><span class="token class-name">String</span> key<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        stringRedisTemplate<span class="token punctuation">.</span><span class="token function">delete</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">Long</span> <span class="token function">increment</span><span class="token punctuation">(</span><span class="token class-name">String</span> key<span class="token punctuation">,</span> <span class="token keyword">long</span> delta<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> stringRedisTemplate<span class="token punctuation">.</span><span class="token function">opsForValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">increment</span><span class="token punctuation">(</span>key<span class="token punctuation">,</span>delta<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br></div></div><ol start="4"><li>redis的其他操作</li></ol> <blockquote><p>注意：使用redis存储对象的时候，一定要将对象序列化（实现Serializable接口或自己写序列化工具类）</p> <p>其他操作（集合、hash等）详见：https://www.jianshu.com/p/56999f2b8e3b</p></blockquote> <h2 id="redis缓存与数据库同步"><a href="#redis缓存与数据库同步" class="header-anchor">#</a> redis缓存与数据库同步</h2> <ul><li><p>新增：数据库新增后，放到缓存中</p></li> <li><p>删除：删除缓存后，再删除数据库相应数据</p></li> <li><p>查询：</p></li></ul> <p><img src="/znote/img/redis/%E7%BC%93%E5%AD%98%E6%9F%A5%E8%AF%A2.png" alt=""></p> <ul><li>更新：</li></ul> <p><img src="/znote/img/redis/%E7%BC%93%E5%AD%98%E6%9B%B4%E6%96%B0.png" alt=""></p></div> <footer class="page-edit" style="display:none;"><div class="edit-link"><a href="https://github.com/f1ybird/edit/master/docs/views/java/redis01.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页！</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2020-06-21 23:07:31</span></div></footer> <!----> <!----></main> <!----> <div class="comments-wrapper" style="display:none;" data-v-0b87bb44><div class="valine-wrapper"><div id="valine"></div></div></div></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-44bd5a18 data-v-44bd5a18><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-44bd5a18><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-44bd5a18></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-44bd5a18></path></svg></div><!----><div data-v-48108b4c><div class="DetailsOpenFlag" style="right:1rem;bottom:9rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;font-size:14px;font-weight:500;display:none;" data-v-48108b4c>
 展开 

</div></div></div></div>
    <script src="/assets/js/app.55c4f7c3.js" defer></script><script src="/assets/js/5.86109dd2.js" defer></script><script src="/assets/js/1.74974061.js" defer></script><script src="/assets/js/2.ab8aa845.js" defer></script><script src="/assets/js/84.6118b266.js" defer></script><script src="/assets/js/18.cfe435f1.js" defer></script>
  </body>
</html>
